#ifndef __CMD_PARSE_H__
#define __CMD_PARSE_H__

typedef void (*cmd_func)(void);
typedef struct __CMD_PARSE{
    const char *cmd_type;
    const char *cmd_help;
    cmd_func fun_ptr;
}CMD_PARSE;

#define NR(array)   sizeof(array)/sizeof(array[0])

extern void led_on_process(void);
extern void led_off_process(void);
extern void motor_on_process(void);
extern void motor_off_process(void);
extern void printf_help(void);
extern void cmd_parse_exit(void);
extern int command_matching(char *cmd_type);
extern void cmd_line(void);

/*命令表定义===》表驱动法*/
#define CMD_SIZE    6
CMD_PARSE CMD_TABLE[CMD_SIZE] = {
    {"led_on",      "turn on led"           ,led_on_process},
    {"led_off",     "turn off led"          ,led_off_process},
    {"motor_on",    "turn on motor"         ,motor_on_process},
    {"motor_off",   "turn off motor"        ,motor_on_process},
    {"help",        "list all cmd info"     ,printf_help},
    {"exit",        "exit program"          ,cmd_parse_exit},
};

#endif /* __CMD_PARSE_H__ */
